package com.electric.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.electric.entity.VoltageLevel;
import com.electric.mapper.VoltageLevelMapper;
import com.electric.service.IVoltageLevelService;

/**
 * <p>
 * 电压等级 服务实现类
 * </p>
 *
 * @author zhangbin
 * @since 2018-08-28
 */
@Service
public class VoltageLevelServiceImpl extends ServiceImpl<VoltageLevelMapper, VoltageLevel> implements IVoltageLevelService {
	
	public Page<VoltageLevel> selectPage(String keyword,int pageNum,int pageSize) {
		EntityWrapper<VoltageLevel> searchWrapper = new EntityWrapper<VoltageLevel>();
		
		if(StringUtils.isNotBlank(keyword)){
			searchWrapper.like("value", keyword);
		}
		
		searchWrapper.orderBy("value", true);
		
		Page<VoltageLevel> page = new Page<VoltageLevel>(pageNum, pageSize);
		
		page = selectPage(page, searchWrapper);
		
		return page;
	}

	@Override
	public List<VoltageLevel> selectAllVoltageLevel() {
		EntityWrapper<VoltageLevel> searchWrapper = new EntityWrapper<VoltageLevel>();
		searchWrapper.orderBy("value", true);
		
		return selectList(searchWrapper);
	}
}
